package com.zhongli.devplatform.mapper.sys;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhongli.devplatform.po.user.ReadRoleMenuPO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ReadRoleMenuMapper extends BaseMapper<ReadRoleMenuPO> {
    @Insert("insert into read_role_menu values(#{roleId},#{menuId})")
    void insert(@Param("roleId") Integer roleId, @Param("menuId") Integer menuId);

    @Delete("delete from read_role_menu where role_id = #{roleId}")
    void deleteByRole(Integer roleId);

    @Select("select menu_id from read_role_menu where role_id = #{roleId} " +
            "and menu_id NOT IN ( SELECT parent_id FROM read_menu where parent_id is not null )")
    List<Integer> listMenuIdByRole(Integer roleId);
}